package com.share.hope.entity.result;

public class R<T> {
    private int code;
    private String msg;
    private T data;

    public R(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public static <T> R<T> success(T data) {
        return new R<T>(20000, "操作成功", data);
    }

    public static <T> R<T> fail(T data) {
        return new R<T>(50000, "操作失败", data);
    }

    public static <T> R<T> loginErr(T data) {
        return new R<T>(50000, "用户不存在或密码错误..", data);
    }

    public static R<String> error(String msg) {
        return new R<String>(50000, msg, null);
    }

    public static R<String> ok(String msg) {
        return new R<String>(20000, msg, null);
    }
}

